package com.special.threademo.jvm.visualVm;

import com.sun.org.apache.bcel.internal.generic.NEW;

/**
 * Created with IDEA2020.3
 * author:LiuYC
 * DateTime:2021/1/26  10:51
 */
public class DeadDemo {
    public static void main(String[] args) {
        new Thread(() -> A.method(), "thread-A").start();
        new Thread(() -> B.method(), "thread-B").start();
        try {
            Thread.sleep(4000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

class A {
    public static synchronized void method() {
        System.out.println("this block is A");
        try {
            Thread.sleep(5000);
            B.method();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class B {
    public static synchronized void method() {
        System.out.println("this block is B");
        try {
            Thread.sleep(5000);
            A.method();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
